<template>
  <div v-loading="loading" class="w-full h-full flex py20px justify-center">
    <el-form ref="formRef" :model="form" :rules="rules" label-width="auto" status-icon>
      <!-- <el-form-item label="账号类型" prop="type">
        <el-radio-group v-model="form.type">
          <el-radio :value="1">正式账号</el-radio>
          <el-radio :value="2">测试账号</el-radio>
        </el-radio-group>
      </el-form-item> -->
      <el-form-item label="账号" prop="account">
        <el-input v-model="form.account" class="w-240px" />
      </el-form-item>
      <el-form-item label="金额" prop="money">
        <el-input v-model="form.money" class="w-240px" />
      </el-form-item>
      <el-form-item label="交易类型" prop="trType">
        <el-radio-group v-model="form.trType">
          <el-radio :value="1">{{ t('status.manual_deposit') }}</el-radio>
          <el-radio :value="2">{{ t('status.manual_credit') }}</el-radio>
          <el-radio :value="3">{{ t('status.promotion_bonus') }}</el-radio>
          <el-radio :value="4">{{ t('status.mistaken_withdrawal') }}</el-radio>
          <el-radio :value="5">{{ t('status.admin_deduction') }}</el-radio>
          <el-radio :value="6">{{ t('status.deposit_reversal') }}</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="流水比例" prop="ratio">
        <el-input v-model="form.ratio" class="w-100px mr-5px" />
        <el-text class="leading-tight" line-clamp="10">% 放空使用默认流水比例（只限2位小数比例）</el-text>
      </el-form-item>
      <el-form-item label="备注" prop="make">
        <el-input v-model="form.make" type="textarea" class="w-250px" />
      </el-form-item>

      <el-form-item label=" ">
        <el-button type="primary" @click="submitForm()">
          {{$t('btn.1')}}
        </el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup>
import Api from '@/api/finance/transfer'
import { onMounted } from 'vue'
const { t } = useI18n();
const loading = ref(false)

const fromList = [
  { label: t("form.账号类型"), prop: "type", hint: "hint.30" },
  { label: t("form.账号"), prop: "customer_service_link", hint: "" },
  { label: t("form.金额"), prop: "money", hint: "" },
  { label: t("form.交易类型"), prop: "trType", hint: "" },
  { label: t("form.流水比例"), prop: "ratio", hint: "" },
  { label: t("form.备注"), prop: "make", type: "textarea", hint: "" },
]
const rules = {
  // type: [{ required: true, message: t('hint.请选择账号类型'), trigger: 'blur' }],
  account: [{ required: true, message: t('hint.请输入账号'), trigger: 'blur' }],
  money: [{ required: true, message: t('hint.请输入金额'), trigger: 'blur' }],
  trType: [{ required: true, message: t('hint.请选择交易类型'), trigger: 'blur' }],
  ratio: [{ required: true, message: t('hint.请输入流水比例'), trigger: 'blur' }],
}
const form = ref({
  // type: '',
  account: "",
  money: "",
  ratio: "",
  trType: "",
  make: ""
})
const formRef = ref()
const submitForm = () => {
  formRef.value.validate((valid, fields) => {
    if (valid) {
      loading.value = true
      Api.put(form.value).then(s => {
        ElMessage.success(t('hint.29'))
      }).finally(() => {
        loading.value = false
      })
    }
  })
}

</script>